#pragma once
#include <QObject>
#include <QString>
#include <QMetaObject>
#include <QStringListModel>
#include "MAVLinkInspectorController.h"
#include "MultiVehicleManager.h"
#include "MAVLinkProtocol.h"
#include "Vehicle.h"
#include "QmlObjectListModel.h"
#include "QGCApplication.h"
#include "UAS.h"
#include <QtCharts/QLineSeries>
// Fordward decls
class Vehicle;

class Swarm : public QObject
{
    Q_OBJECT

public:
    Swarm();
    virtual ~Swarm();
    Q_INVOKABLE void sendStartCommand();
    Q_INVOKABLE void update_status();
    Q_PROPERTY(QString          uavnum       READ uavnum   WRITE setUavnum   NOTIFY valueChanged)
    QString         uavnum           ()
    {
        return _uavnum;
    }
    Q_PROPERTY(QString          ready_num       READ ready_num   WRITE setReady_num   NOTIFY valueChanged2)
    QString         ready_num           ()
    {
        return _ready_num;
    }
    Q_PROPERTY(QString          uavcount       READ uavcount   WRITE setUavcount   NOTIFY valueChanged3)
    QString         uavcount           ()
    {
        return _uavcount;
    }
    Q_PROPERTY(QString          transdelay       READ transdelay   WRITE setTransdelay   NOTIFY valueChanged4)
    QString         transdelay           ()
    {
        return _transdelay;
    }


    void setUavnum(QString uavnum);
    void setUavcount(QString uavcount);
    void setReady_num(QString ready_num);
    void setTransdelay(QString transdelay);
signals:
    void    valueChanged();
    void    valueChanged2();
    void    valueChanged3();
    void    valueChanged4();

    void    _testChanged();

private slots:
    void _receiveMessage            (LinkInterface* link, mavlink_message_t message);

private:
    int __uav_count=0;
    QDateTime currentDateTime = QDateTime::currentDateTime();
    qint64 milliseconds,premilliseconds,time_delay;
    QTimer timer_status;
    QString     _uavnum="0";
    QString     _ready_num="0";
    QString     _uavcount="0";
    QString     _transdelay="0";
    QmlObjectListModel* _vehiclelist;
    Vehicle*      _vehicle;
    bool start_swarm=false;
};

